#!/bin/bash

##################################################
#
#  @desc: 加载flume采集的日志，到ods表分区中
#  @auth: HUNTER.DUAN
#  @date: 2020-08-11
#   
##################################################

export HIVE_HOME=/opt/apps/apache-hive-3.1.2-bin/

datestr=`date -d'-1 day' +%Y-%m-%d`

if [ $1 ]
then
datestr=$1
fi


year=`echo $datestr|cut -d"-" -f1`
month=`echo $datestr|cut -d"-" -f2`
day=`echo $datestr|cut -d"-" -f3`


${HIVE_HOME}/bin/hive -e "load data inpath '/eventlog/app_event/${datestr}' into table ods.app_event_log partition (y='${year}',m='${month}',d='${day}')"


if [ $? -eq 0 ]
then 
echo "execution successed ..............."
else
echo "execution failed ..............."
fi